/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package azhar.engine;

import azhar.view.Main;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.smslib.*;

/**
 *
 * @author Al-Insan
 */
public class OrphanedMessageNotification implements IOrphanedMessageNotification {

    private Main main;

    public OrphanedMessageNotification(Main m) {
        main = m;
    }

    public boolean process(AGateway gateway, InboundMessage msg) {
        System.out.println(">>> Orphaned message part detected from " + gateway.getGatewayId());
        System.out.println(msg);
        try {
            gateway.deleteMessage(msg);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
        }
//         Since we are just testing, return FALSE and keep the orphaned message part.
        return true;
    }
}
